public class Homework2 {
    public static void main(String[] args) {
        int[] array = {12, 23, 34, 45, 56, 67, 78, 89};
        int num = 49;
        int len = array.length;
        int flag = 0;
        for (int i = 0; i < len; i++) {
            if (num > array[i] && num < array[i + 1]) {
                flag = i;
                break;
            }
        }
        len++;
        int[] temp = new int[len];
        for (int j = 0; j <= flag; j++) {
            temp[j] = array[j];
        }
        array[flag] = num;
        for (int j = flag + 1; j < temp.length; j++) {
            temp[j] = array[j - 1];
        }
        for (int k = 0; k < temp.length; k++) {
            System.out.print(temp[k] + " ");
        }
    }
}
